home *** CD-ROM | disk | FTP | other *** search
- /* os_mac_stringio.c */
- /* 14Aug93 e */
-
- #if defined(THINK_C)
-
- #include <MacHeaders>
- #include <console.h>
- #include <stddef.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <ansi_private.h>
-
- #include "os_mac.h"
-
- static int stringio( FILE *fp, int i )
- {
- int result = 0;
- switch (i)
- { case 0: /* read */
- fp->eof = 0;
- if ((result = fp->cnt) == 0)
- { fp->eof = 1;
- result = EOF;
- }
- break;
- case 1: /* write */
- break;
- case 2: /* close */
- break;
- }
- return(result);
- }
-
- FILE * e_open_string_stream( char *str )
- { int cnt;
- FILE *fp = __getfile();
-
- if ( fp == NULL)
- return(fp); /* ML wanted -1 */
- fclose(fp);
- fp->refnum = -1;
- fp->window = (void *)(-1);
- cnt = strlen(str);
- setvbuf(fp, NULL, _IOFBF, cnt + 1 );
- strcpy( fp->buf, str );
- fp->ptr = (unsigned char *)fp->buf;
- fp->cnt = cnt;
- fp->proc = stringio;
- return(fp); /* ML wanted: (int )fileno(fp) */
- }
-
- #elif defined(__MWERKS__)
-
- #include <stdio.h>
-
- FILE * e_open_string_stream( char *str )
- { return stderr; /* help! */
- }
-
- #else
- "unknown compiler"
- #endif
-